package com.nbgs.demo.dao;

import com.nbgs.demo.model.Meter;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.sql.Timestamp;
import java.util.Date;

public interface MeterMapper {

    //录入水表信息
    @Options(useGeneratedKeys=true, keyProperty="meterId", keyColumn="meter_id")
    @Insert("insert into t_meter(meter_date,meter_address,meter_state,area_num) value(#{meterDate},#{meterAddress},#{meterState},#{areaNum})")
    void addMeter(Meter meter);


    //修改水表信息

    //修改指定meterId的信息
    @Update("<script>\n" +
            "update t_meter\n" +
            "<set>\n" +
            "<if test=\"meterState!=null and meterState!=''\">\n" +
            " meter_state=#{meterState}\n" +
            "</if>\n" +
            "</set>\n" +
            "where meter_id=#{meterId}\n"+
            "</script>")
    void updateMeter(Meter meter);
}
